<@_sysApp id=id><#assign a=object/></@_sysApp>
<form method="post" action="sysApp/save.do?callbackType=closeCurrent&navTabId=sysApp/list" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
	<div class="formBar">
		<ul>
			<li><button type="submit" class="buttonActive">保存</button></li>
			<li><button type="button" class="button close">关闭</button></li>
		</ul>
	</div>
	<div class="pageFormContent" layoutH="60">
		<input name="id" type="hidden" value="${id!}" />
		<input name="appKey" type="hidden" value="${(a.appKey)!getUUID()}"/>
		<input name="appSecret" type="hidden" value="${(a.appSecret)!getUUID()}"/>
		<dl class="nowrap">
			<dt>渠道:</dt>
			<dd><input class="required" name="channel" type="text" size="30" value="${(a.channel)!}"/></dd>
		</dl>
		<fieldset class="ownsAllRight">
			<legend>接口授权</legend>
			<ul id="authorizedApis" class="tree treeFolder treeCheck expand">
				<li>
					<a href="javascript:;" onclick="return false;">所有接口</a>
					<ul>
						<li>
							<a data-id="0" href="javascript:;" onclick="return false;">指令接口</a>
							<ul></ul>
						</li>
						<li>
							<a data-id="1" href="javascript:;" onclick="return false;">方法接口</a>
							<ul></ul>
						</li>
						<li>
							<a data-id="2" href="javascript:;" onclick="return false;">定制接口</a>
							<ul></ul>
						</li>
					</ul>
				</li>
			</ul>
		</fieldset>
	</div>
<script>
var apisArray=['/api/directives','/api/methods','/api/apis'];
var authorizedApis = '${(a.authorizedApis)!}'.split(",");
var i=0;
for (api in apisArray){
	getApi(api);
}
function getApi(api){
	$.ajax({
		url:'${base}'+apisArray[api],
		type: 'GET',
		contentType:'application/json; charset=UTF-8',
		dataType: 'json',
		success: function (dataList) {
			$(dataList).each(function(index,data){
				var style='';
				if('true'==data.needAppToken){
					$('#authorizedApis a[data-id='+api+']',navTab.getCurrentPanel()).next().append('<li><a tname="apis" tvalue="'+data.name+'">'+data.name+'</a></li>');
				}
			});
			if(++i==apisArray.length){
				$("#authorizedApis", navTab.getCurrentPanel()).addClass('tree').jTree();
				for(authorizedApi in authorizedApis){
					$("input[type=checkbox][value="+authorizedApis[authorizedApi]+"]", navTab.getCurrentPanel()).click();
				}
			}
		}
	});
}
</script>
</form>